<%@ include file = "/js/_of_js.jsp"%>
<script type="text/javascript" src="/FCKeditor/fckeditor.js"></script>
<script>
    function goback()
    {
        window.location.href = "<%= request.getContextPath()%>/moduleinfor/back2LastList.jsp";
    }
    
    function reset()
    {
        
        <%        
        // 域
        Object[] domains = typeManager.getByCode("domain").getSubTypes().toArray();
        for(int i = 0; i < domains.length; i ++)
        {
            Type domain = (Type)domains[i];
            %>addOption(detailForm.domainId,"<%= domain.getId()%>","<%= domain.getName()%>");<%
        }       
        %>
        if(domainId != null)
        {
            $('domainId').value = domainId;
            domainId = null;
        }
    }
    function bodyLoadJS()
    {
        // 被聚焦的控件
        detailForm.domainId.focus(); 
    }
</script>
    <form id="detailForm" name="detailForm" action="<%= request.getContextPath()%>/moduleinfor/Controller.jsp" method="post" >
        <tr>
            <td class="detailTD11">领域&nbsp;&nbsp;</td>
            <td class="detailTD12">
                <select id="domainId" name="domainId"  onkeyup="nextOfFocused(this)" afterFocusedJS="" of="true">					
				</select>
            </td>
            <script type="text/javascript">
                new Form.Element.Observer('domainId',1, 
                        function(element, value) 
                        {                               
                            new Ajax.Updater('initSubjectJs', 
                                '<%= request.getContextPath()%>/moduleinfor/basedata/type/ajax/findBySuperTypeId.jsp', 
                                {asynchronous:true, evalScripts:true, parameters:'objId=subjectId&value='+value});
                         })
            </script>
			<td class="detailTD11">学科&nbsp;&nbsp;</td>
            <td class="detailTD12">                
                <select id="subjectId" name="subjectId"  onkeyup="nextOfFocused(this)" afterFocusedJS="" of="true"></select>
                <span id="initSubjectJs"></span>
            </td>
            <script type="text/javascript">
                new Form.Element.Observer('subjectId',1, 
                        function(element, value) 
                        { 
                            new Ajax.Updater('initCourseJs', 
                                '<%= request.getContextPath()%>/moduleinfor/basedata/type/ajax/findBySuperTypeId.jsp', 
                                {asynchronous:true, evalScripts:true, parameters:'objId=courseId&value='+value})
                        })
            </script>
			<td class="detailTD11">课程&nbsp;&nbsp;</td>
            <td class="detailTD12">
                <select id="courseId" name="courseId" onkeyup="nextOfFocused(this)" afterFocusedJS="" of="true"></select>
                <span id="initCourseJs"></span>
            </td>
            <script type="text/javascript">
                new Form.Element.Observer('courseId',1, 
                        function(element, value) 
                        { 
                            new Ajax.Updater('initUnitJs', 
                                '<%= request.getContextPath()%>/moduleinfor/basedata/type/ajax/findBySuperTypeId.jsp', 
                                {asynchronous:true, evalScripts:true, parameters:'objId=unitId&value='+value});
//                            new Ajax.Updater('initknowledgeTypeJs', 
//                                '<%= request.getContextPath()%>/moduleinfor/basedata/type/knowledgeType/findBySubjectId4ajax.jsp', 
//                                {asynchronous:true, evalScripts:true, parameters:'objId=knowledgeTypeId&value='+value});
                        })
            </script>
        </tr>
        <tr >
            
			<td class="detailTD21">章&nbsp;&nbsp;</td>
            <td class="detailTD22">
                <select name="unitId" onkeyup="nextOfFocused(this)" afterFocusedJS="" of="true"></select>
                <span id="initUnitJs"></span>
            </td>
            <script type="text/javascript">
                new Form.Element.Observer('unitId',1, 
                        function(element, value) 
                        { 
                            new Ajax.Updater('initSectionJs', 
                                '<%= request.getContextPath()%>/moduleinfor/basedata/type/ajax/findBySuperTypeId.jsp', 
                                {asynchronous:true, evalScripts:true, parameters:'objId=sectionId&value='+value})
                        })
            </script>
			<td class="detailTD21">节&nbsp;&nbsp;</td>
            <td class="detailTD22">
                <select name="sectionId"  onkeyup="nextOfFocused(this)" afterFocusedJS="" of="true">
				</select><span id="initSectionJs"></span>
            </td>
            <script type="text/javascript">
                new Form.Element.Observer('sectionId',1, 
                        function(element, value) 
                        {   
                            new Ajax.Updater('initKnowledgePointJs', 
                                '<%= request.getContextPath()%>/moduleinfor/basedata/type/ajax/findBySuperTypeId.jsp', 
                                {asynchronous:true, evalScripts:true, parameters:'objId=knowledgePointId&value='+value})
                        })
            </script>
			<td  class="detailTD21">知识点&nbsp;&nbsp;</td>
            <td class="detailTD22">
                <select id="knowledgePointId" name="knowledgePointId"  onkeyup="nextOfFocused(this)" afterFocusedJS="" of="true">
				</select>&nbsp;&nbsp;<span id="knowledgePointId_error"></span>
                <span id="initKnowledgePointJs"></span>
            </td>
        </tr>     
        </form>
        <script>
            function changeFck(obj)
            {
                for(var i = 0; i < 9; i ++)
                {
                    eval("$('fck" + i + "').style.fontWeight = '';");
                    eval("$('fck" + i + "inst').style.display = 'none';");
                }
                obj.style.fontWeight = "bold";
                eval("$('" + obj.id + "inst').style.display = '';");
            }

            function learnIt(id)
            {
                new Ajax.Updater('titlespan', 
                                 'trtitle.jsp', 
                                 {asynchronous:true, evalScripts:true, parameters:'id=' + id});
                
                new Ajax.Updater('trCCSpan', 
                                 'trcontentControl.jsp', 
                                 {asynchronous:true, evalScripts:true, parameters:'id=' + id});
                new Ajax.Updater('trContentSpan', 
                                 'trcontent.jsp', 
                                 {asynchronous:true, evalScripts:true, parameters:'id=' + id});
                showTrContent();
                
            }
            function showTrList()
            {
                $('trstr').style.display = '';
                $('titletr').style.display = 'none';
                $('trcontenttr').style.display = 'none';
                $('nextTr').disabled = true;
            }

            function showTrContent()
            {
                $('trstr').style.display = 'none';
                $('titletr').style.display = '';
                $('trcontenttr').style.display = '';
                beforeInitContent();
                $('nextTr').disabled = false;
            }

            function beforeInitContent()
            {
                $('trContentSpan').innerHTML = "<div width='100%' align='center'>初始化中...</div>";
            }
        </script>
        
            <tr id="titletr" style="display:none">
                <td class="detailTD11">标题&nbsp;&nbsp;</td>
                <td class="detailTD12" >
                    <span id="titlespan"></span>
                </td>  
                <td class="detailTD11">出版社&nbsp;&nbsp;</td>
                <td class="detailTD12" >
                    <span id="publishCompanySpan"></span>
                </td> 
                <td class="detailTD11">编者&nbsp;&nbsp;</td>
                <td class="detailTD12" >
                    <span id="authorNameSpan"></span>
                </td> 
            </tr>
            <script>
                function nextTest(kpId)
                {
                    $('tryButton').disabled = true;
                    new Ajax.Updater('testSpan', 
                                     'testQuest.jsp', 
                                    {asynchronous:true, evalScripts:true, parameters:'kpId='+kpId});
                }
                
                // 选择题选项
                function checkTr(obj,rscount,isSimpleSelect)
                {
                    if(isSimpleSelect)
                    {
                        for(var i = 0; i < rscount; i ++)
                        {
                            $('srs' + i).checked = false;
                        }
                        obj.checked = true;
                    }
                }
                
                // 显示答案
                function showRs(isSubjective)
                {
                    $('resolutionTitle').style.display = "";
                    $('resolutionTr').style.display = "";
                }
            </script>
            <tr id="trcontenttr" style="display:none">
                <td class="detailTD21"><span id="trCCSpan"></span></td>
                <td class="detailTD22" colspan="5">
                    <span id="trContentSpan"></span>
                </td>  
            </tr>
            <tr id="trstr" style="display:none">
                <td class="detailTD11">资源</td>
                <td class="detailTD12" colspan="5">
                <span id="trsspan"></span>
                </td>  
            </tr>
    
    <script>
        new Form.Observer('detailForm',
                          2,
                          function (element,value)
                          {
                              //alert($F('knowledgePointId'));
                              if($F('knowledgePointId') != null)
                              {
                                  new Ajax.Updater('trsspan', 
                                    'trlist.jsp', 
                                    {asynchronous:true, evalScripts:true, parameters:Form.serialize('detailForm')})
                              }
                              else
                              {
                                  $('trsspan').innerHTML = "";
                              }
                          });
    </script>